


import re
import uuid
from .config import *

def is_valid_uuid4(uuid_str):
    try:
        # 尝试将字符串转换为UUID对象
        val = uuid.UUID(uuid_str, version=4)
        
        # 使用正则表达式检查UUID4的格式和特征
        uuid4_regex = re.compile(
            r'^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\Z',
            re.IGNORECASE
        )
        return bool(uuid4_regex.match(uuid_str))
    except ValueError:
        # 如果转换失败，则不是有效的UUID
        return False


def is_valid_aid(aid: str) -> bool:
    pattern = r'^\d{4}\.\d{5}(v\d+)?$'
    match = re.match(pattern, aid)
    return match is not None


